package com.datang.pet.common.response;



/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-05-09 19:55
 * @notify 全局API返回值包装类
 * @version 1.0
 */


public class Result {

    private Integer code;
    private String message;
    private Object data;

    /*
     * @author 顶风少年
     * @date 2019/5/9 23:24
     * @mail dfsn199703132038@foxmail.com
     * @throws
     * @param
     * @param code 状态码
     * @param message 返回说明
     * @param data 返回数据
     * @result
     * @notify
     * version 1.0
     */
    public Result(Integer code, String message, Object data) {
        this.data = data;
        this.code = code;
        this.message = message;
    }

    public static Result ok(String message, Object data) {
        return new Result(200, message, data);
    }

    public static Result ok(Object data) {
        return new Result(200, "成功", data);
    }

    public static Result err(String message) {
        return new Result(500, message, null);
    }

    public static Result err() {
        return new Result(500, "失败", null);
    }

    public static Result err(String message, Object data) {
        return new Result(500, message, data);
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
